<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    let str = '2022-5-20';
    const reg = /^(?<year>\d+)-(?<month>\d+)-(?<day>\d+)$/;
    let res = reg.exec(str);
    console.log(res.groups.year);
    console.log(res.groups.month);
    console.log(res.groups.day);

    /*const reg = /^(\d+)-(\d+)-(\d+)$/;
    let res = reg.exec(str);
    console.log(res);*/

    /*let str = '<a href="http://www.atguigu.com">尚硅谷</a>';
    const reg = /<a href="(?<url>.*)">(?<text>.*)<\/a>/;
    const result = reg.exec(str);
    console.log(result.groups.url);
    console.log(result.groups.text);*/
</script>
</html>